using UnityEngine;

namespace Coffee.UIExtensions
{
    // [Assembly-CSharp.dll].Coffee.UIExtensions.UIDissolve
    public class UIDissolve : UIEffectBase
    {
        // Fields
        public const string shaderName = "UI/Hidden/UI-Effect-Dissolve";
        private static readonly Coffee.UIExtensions.ParameterTexture _ptex;
        private float m_EffectFactor;
        private float m_Width;
        private float m_Softness;
        private UnityEngine.Color m_Color;
        private Coffee.UIExtensions.ColorMode m_ColorMode;
        private UnityEngine.Texture m_NoiseTexture;
        protected Coffee.UIExtensions.EffectArea m_EffectArea;
        private bool m_KeepAspectRatio;
        private Coffee.UIExtensions.EffectPlayer m_Player;
        private float m_Duration;
        private UnityEngine.AnimatorUpdateMode m_UpdateMode;
        private Coffee.UIExtensions.MaterialCache _materialCache;
        
        // Properties
        public float location { get; set; }
        public float effectFactor { get; set; }
        public float width { get; set; }
        public float softness { get; set; }
        public UnityEngine.Color color { get; set; }
        public UnityEngine.Texture noiseTexture { get; set; }
        public Coffee.UIExtensions.EffectArea effectArea { get; set; }
        public bool keepAspectRatio { get; set; }
        public Coffee.UIExtensions.ColorMode colorMode { get; }
        public bool play { get; set; }
        public bool loop { get; set; }
        public float duration { get; set; }
        public float loopDelay { get; set; }
        public UnityEngine.AnimatorUpdateMode updateMode { get; set; }
        public override Coffee.UIExtensions.ParameterTexture ptex { get; }
        private Coffee.UIExtensions.EffectPlayer _player { get; }
        
        // Methods
        public float get_location()
        {
            return (float)this.m_EffectFactor;
        }
        public void set_location(float value)
        {
            double val_10;
            float val_1 = (value >= 0) ? 1f : 0f;
            float val_10 = System.Math.Abs(this.m_EffectFactor);
            float val_11 = System.Math.Abs(val_1);
            float val_12 = 1E-06f;
            val_12 = ((val_10 > val_11) ? (val_10) : (val_11)) * val_12;
            float val_13 = 8f;
            val_13 = mem[536889545] * val_13;
            float val_4 = (val_12 > val_13) ? (val_12) : (val_13);
            if((val_1 ?? this.m_EffectFactor) < 0)
            {
                    return;
            }
            
            this.m_EffectFactor = val_1;
            val_10 = ???;
            goto typeof(Coffee.UIExtensions.UIDissolve).__il2cppRuntimeField_2D8;
        }
        public float get_effectFactor()
        {
            return (float)this.m_EffectFactor;
        }
        public void set_effectFactor(float value)
        {
            double val_10;
            float val_1 = (value >= 0) ? 1f : 0f;
            float val_10 = System.Math.Abs(this.m_EffectFactor);
            float val_11 = System.Math.Abs(val_1);
            float val_12 = 1E-06f;
            val_12 = ((val_10 > val_11) ? (val_10) : (val_11)) * val_12;
            float val_13 = 8f;
            val_13 = mem[536889545] * val_13;
            float val_4 = (val_12 > val_13) ? (val_12) : (val_13);
            if((val_1 ?? this.m_EffectFactor) < 0)
            {
                    return;
            }
            
            this.m_EffectFactor = val_1;
            val_10 = ???;
            goto typeof(Coffee.UIExtensions.UIDissolve).__il2cppRuntimeField_2D8;
        }
        public float get_width()
        {
            return (float)this.m_Width;
        }
        public void set_width(float value)
        {
            double val_10;
            float val_1 = (value >= 0) ? 1f : 0f;
            float val_10 = System.Math.Abs(this.m_Width);
            float val_11 = System.Math.Abs(val_1);
            float val_12 = 1E-06f;
            val_12 = ((val_10 > val_11) ? (val_10) : (val_11)) * val_12;
            float val_13 = 8f;
            val_13 = mem[536889545] * val_13;
            float val_4 = (val_12 > val_13) ? (val_12) : (val_13);
            if((val_1 ?? this.m_Width) < 0)
            {
                    return;
            }
            
            this.m_Width = val_1;
            val_10 = ???;
            goto typeof(Coffee.UIExtensions.UIDissolve).__il2cppRuntimeField_2D8;
        }
        public float get_softness()
        {
            return (float)this.m_Softness;
        }
        public void set_softness(float value)
        {
            double val_10;
            float val_1 = (value >= 0) ? 1f : 0f;
            float val_10 = System.Math.Abs(this.m_Softness);
            float val_11 = System.Math.Abs(val_1);
            float val_12 = 1E-06f;
            val_12 = ((val_10 > val_11) ? (val_10) : (val_11)) * val_12;
            float val_13 = 8f;
            val_13 = mem[536889545] * val_13;
            float val_4 = (val_12 > val_13) ? (val_12) : (val_13);
            if((val_1 ?? this.m_Softness) < 0)
            {
                    return;
            }
            
            this.m_Softness = val_1;
            val_10 = ???;
            goto typeof(Coffee.UIExtensions.UIDissolve).__il2cppRuntimeField_2D8;
        }
        public UnityEngine.Color get_color()
        {
            return new UnityEngine.Color() {r = this.m_Color};
        }
        public void set_color(UnityEngine.Color value)
        {
            UnityEngine.Color val_5 = this.m_Color;
            val_5 = val_5 - value.r;
            float val_1 = S5 - value.g;
            val_5 = val_5 * val_5;
            val_1 = val_1 * val_1;
            val_5 = val_5 + val_1;
            float val_2 = S6 - value.b;
            val_2 = val_2 * val_2;
            val_5 = val_2 + val_5;
            val_5 = ((S7 - value.a) * (S7 - value.a)) + val_5;
            if(val_5 < 0)
            {
                    return;
            }
            
            this.m_Color = value;
            mem[1152921504930430468] = value.g;
            mem[1152921504930430472] = value.b;
            mem[1152921504930430476] = value.a;
            goto typeof(Coffee.UIExtensions.UIDissolve).__il2cppRuntimeField_2D8;
        }
        public UnityEngine.Texture get_noiseTexture()
        {
            if(this.m_NoiseTexture == null)
            {
                    return this.graphic.GetTexture(name:  -1610600783);
            }
            
            return (UnityEngine.Texture)this.m_NoiseTexture;
        }
        public void set_noiseTexture(UnityEngine.Texture value)
        {
            UnityEngine.Object val_10;
            UnityEngine.Texture val_11;
            val_10 = value;
            val_11 = this.m_NoiseTexture;
            if(val_11 == val_10)
            {
                    return;
            }
            
            this.m_NoiseTexture = val_10;
            val_10 = this.graphic;
            if((UnityEngine.Object.op_Implicit(exists:  val_10)) == false)
            {
                    return;
            }
            
            val_10 = ???;
            val_11 = ???;
            goto typeof(Coffee.UIExtensions.UIDissolve).__il2cppRuntimeField_2C8;
        }
        public Coffee.UIExtensions.EffectArea get_effectArea()
        {
            return (Coffee.UIExtensions.EffectArea)this.m_EffectArea;
        }
        public void set_effectArea(Coffee.UIExtensions.EffectArea value)
        {
            if(this.m_EffectArea == value)
            {
                    return;
            }
            
            this.m_EffectArea = value;
            goto typeof(Coffee.UIExtensions.UIDissolve).__il2cppRuntimeField_2D8;
        }
        public bool get_keepAspectRatio()
        {
            return (bool)this.m_KeepAspectRatio;
        }
        public void set_keepAspectRatio(bool value)
        {
            bool val_1 = value;
            if(this.m_KeepAspectRatio == val_1)
            {
                    return;
            }
            
            this.m_KeepAspectRatio = val_1;
            goto typeof(Coffee.UIExtensions.UIDissolve).__il2cppRuntimeField_2D8;
        }
        public Coffee.UIExtensions.ColorMode get_colorMode()
        {
            return (Coffee.UIExtensions.ColorMode)this.m_ColorMode;
        }
        public bool get_play()
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            return (bool)val_1.play;
        }
        public void set_play(bool value)
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            val_1.play = value;
        }
        public bool get_loop()
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            return (bool)val_1.loop;
        }
        public void set_loop(bool value)
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            val_1.loop = value;
        }
        public float get_duration()
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            return (float)val_1.duration;
        }
        public void set_duration(float value)
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            val_1.duration = 0.1f;
        }
        public float get_loopDelay()
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            return (float)val_1.loopDelay;
        }
        public void set_loopDelay(float value)
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            val_1.loopDelay = 0f;
        }
        public UnityEngine.AnimatorUpdateMode get_updateMode()
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            return (UnityEngine.AnimatorUpdateMode)val_1.updateMode;
        }
        public void set_updateMode(UnityEngine.AnimatorUpdateMode value)
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            val_1.updateMode = value;
        }
        public override Coffee.UIExtensions.ParameterTexture get_ptex()
        {
            if(mem[536895001] != 0)
            {
                    return (Coffee.UIExtensions.ParameterTexture)mem[536894961];
            }
            
            536894777 = 536894777;
            return (Coffee.UIExtensions.ParameterTexture)mem[536894961];
        }
        public override void ModifyMaterial()
        {
            object val_13;
            UnityEngine.Texture val_14;
            Coffee.UIExtensions.MaterialCache val_15;
            val_13 = this;
            if((UnityEngine.Object.op_Implicit(exists:  this.m_NoiseTexture)) != false)
            {
                    val_14 = this.m_NoiseTexture;
                int val_2 = val_14.GetInstanceID();
            }
            else
            {
                    val_14 = 0;
            }
            
            if(this._materialCache != null)
            {
                    if(this._materialCache._hash_k__BackingField == 4294967296)
            {
                    if(this.isActiveAndEnabled != false)
            {
                    if((UnityEngine.Object.op_Implicit(exists:  X22)) == true)
            {
                goto label_9;
            }
            
            }
            
            }
            
                val_15 = this._materialCache;
                Coffee.UIExtensions.MaterialCache.Unregister(cache:  val_15);
                this._materialCache = 0;
            }
            
            label_9:
            if((this.isActiveAndEnabled == false) || ((UnityEngine.Object.op_Implicit(exists:  val_15)) == false))
            {
                goto label_13;
            }
            
            val_15 = this.m_NoiseTexture;
            if((UnityEngine.Object.op_Implicit(exists:  val_15)) == false)
            {
                goto label_15;
            }
            
            if(this._materialCache != null)
            {
                    if(11993091 == 4294967296)
            {
                goto label_17;
            }
            
            }
            
            System.Func<System.Object> val_8 = 536874841;
            val_15 = val_8;
            val_8 = new System.Func<System.Object>(object:  this, method:  1610678917);
            this._materialCache = Coffee.UIExtensions.MaterialCache.Register(hash:  4294967296, texture:  this, onCreateMaterial:  val_15);
            label_17:
            UnityEngine.UI.Graphic val_10 = this.graphic;
            goto label_22;
            label_13:
            UnityEngine.UI.Graphic val_11 = this.graphic;
            label_25:
            label_22:
            val_13 = ???;
            goto typeof(UnityEngine.UI.Graphic).__il2cppRuntimeField_348;
            label_15:
            UnityEngine.UI.Graphic val_12 = val_13.graphic;
            goto label_25;
        }
        public override void ModifyMesh(UnityEngine.UI.VertexHelper vh)
        {
            Coffee.UIExtensions.IParameterTexture val_16;
            float val_17;
            float val_18;
            var val_20;
            var val_21;
            float val_22;
            val_16 = this;
            if(this.isActiveAndEnabled == false)
            {
                    return;
            }
            
            UnityEngine.Texture val_3 = this.noiseTexture;
            val_17 = -1f;
            if(this.m_KeepAspectRatio != false)
            {
                    if((UnityEngine.Object.op_Implicit(exists:  val_3)) != false)
            {
                    val_18 = (float)val_3;
                val_17 = (float)val_3 / val_18;
            }
            
            }
            
            UnityEngine.Rect val_6 = Coffee.UIExtensions.EffectAreaExtensions.GetEffectArea(area:  this.m_EffectArea, vh:  vh, graphic:  this.graphic, aspectRatio:  val_17);
            UnityEngine.UI.Graphic val_7 = this.graphic;
            int val_8 = vh.currentVertCount;
            if(val_8 < 1)
            {
                    return;
            }
            
            val_16 = val_8;
            var val_17 = 0;
            label_19:
            vh.PopulateUIVertex(vertex:  new UnityEngine.UIVertex() {position = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, normal = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, tangent = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, color = new UnityEngine.Color32(), uv0 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv1 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv2 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv3 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}}, i:  0);
            if(0 == 0)
            {
                goto label_13;
            }
            
            val_20 = 536894795;
            if(mem[536895019] == 0)
            {
                    val_20 = 536894795;
            }
            
            var val_16 = mem[536894979];
            var val_9 = val_17 & 3;
            if(val_9 >= (mem[536894979] + 24))
            {
                goto label_16;
            }
            
            val_16 = val_16 + val_9;
            val_21 = mem[(mem[536894979] + (0 & 3)) + 32];
            val_21 = (mem[536894979] + (0 & 3)) + 32;
            val_22 = mem[(mem[536894979] + (0 & 3)) + 32 + 4];
            val_22 = (mem[536894979] + (0 & 3)) + 32 + 4;
            goto label_18;
            label_13:
            float val_10 = val_6.m_XMin.width;
            val_10 = 0f / val_10;
            val_10 = val_10 + 0.5f;
            val_22 = 0f;
            float val_12 = val_6.m_XMin.height;
            val_12 = 0f / val_12;
            val_12 = val_12 + 0.5f;
            label_18:
            float val_13 = Packer.ToFloat(x:  0f, y:  0f);
            float val_14 = Packer.ToFloat(x:  (val_10 >= 0) ? val_6.m_YMin : (val_22), y:  val_22, z:  this.GetNormalizedIndex(target:  this));
            vh.SetUIVertex(vertex:  new UnityEngine.UIVertex() {position = new UnityEngine.Vector3(), normal = new UnityEngine.Vector3(), tangent = new UnityEngine.Vector4(), color = new UnityEngine.Color32(), uv0 = new UnityEngine.Vector4(), uv1 = new UnityEngine.Vector4(), uv2 = new UnityEngine.Vector4(), uv3 = new UnityEngine.Vector4()}, i:  0);
            val_17 = val_17 + 1;
            if(val_16 != val_17)
            {
                goto label_19;
            }
            
            return;
            label_16:
        }
        protected override void SetDirty()
        {
            this.RegisterMaterial(mat:  this.graphic);
            float val_3 = (this.m_EffectFactor >= 0) ? (S2 * 255f) : 0f;
            this.SetData(target:  this, channelId:  0, value:  (val_3 < 0) ? ((int)val_3) : ((int)val_3));
            float val_6 = (this.m_Width >= 0) ? (S2 * 255f) : 0f;
            this.SetData(target:  this, channelId:  1, value:  (val_6 < 0) ? ((int)val_6) : ((int)val_6));
            float val_9 = (this.m_Softness >= 0) ? (S2 * 255f) : 0f;
            this.SetData(target:  this, channelId:  2, value:  (val_9 < 0) ? ((int)val_9) : ((int)val_9));
            float val_12 = (this.m_Color >= 0) ? (S2 * 255f) : 0f;
            this.SetData(target:  this, channelId:  4, value:  (val_12 < 0) ? ((int)val_12) : ((int)val_12));
            float val_15 = (val_12 >= 0) ? (S2 * 255f) : 0f;
            this.SetData(target:  this, channelId:  5, value:  (val_15 < 0) ? ((int)val_15) : ((int)val_15));
            float val_18 = (val_15 >= 0) ? (S2 * 255f) : 0f;
            this.SetData(target:  this, channelId:  6, value:  (val_18 < 0) ? ((int)val_18) : ((int)val_18));
        }
        public void Play()
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            val_1._time = 0f;
            val_1.play = true;
        }
        public void Stop()
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            val_1.play = false;
        }
        protected override void OnEnable()
        {
            this.OnEnable();
            System.Action<System.Single> val_2 = 536873435;
            val_2 = new System.Action<System.Single>(object:  this, method:  1610678919);
            this._player.OnEnable(callback:  val_2);
        }
        protected override void OnDisable()
        {
            Coffee.UIExtensions.MaterialCache.Unregister(cache:  this._materialCache);
            this._materialCache = 0;
            this._player.OnDisable();
            this.OnDisable();
        }
        private Coffee.UIExtensions.EffectPlayer get__player()
        {
            Coffee.UIExtensions.EffectPlayer val_2 = this.m_Player;
            if(val_2 != null)
            {
                    return val_2;
            }
            
            object val_1 = 536885475;
            val_2 = val_1;
            mem[536885503] = 1065353216;
            val_1 = new System.Object();
            this.m_Player = val_2;
            return val_2;
        }
        public UIDissolve()
        {
            mem[1152921504930430468] = 1048576000;
            mem[1152921504930430476] = 1065353216;
            this.m_EffectFactor = ;
            this.m_Width = ;
            this.m_Softness = 0.5f;
            this.m_Color = 0;
            this.m_Duration = 1f;
            this = new UnityEngine.UI.BaseMeshEffect();
        }
        private static UIDissolve()
        {
            Coffee.UIExtensions.ParameterTexture val_1 = 536890543;
            val_1 = new Coffee.UIExtensions.ParameterTexture(channels:  8, instanceLimit:  128, propertyName:  -1610600767);
            mem2[0] = val_1;
            throw new NullReferenceException();
        }
        private UnityEngine.Material <ModifyMaterial>b__56_0()
        {
            UnityEngine.Material val_1 = 536889313;
            val_1 = new UnityEngine.Material(source:  28164096);
            val_1.name = val_1.name + -1610600873(-1610600873) + this.m_NoiseTexture.name;
            val_1.SetTexture(name:  -1610600783, value:  this.m_NoiseTexture);
            return val_1;
        }
        private void <OnEnable>b__61_0(float f)
        {
            this.effectFactor = f;
        }
    
    }

}
